/**
 * 1、接收发送的内容
 * 2、接收发送的消息类型
 */
const createResData = (res) => {
  const {
    FromUserName,
    ToUserName,
    MsgType = 'text',
    Content = '默认回复',
    MediaId,
    Title = '默认标题',
    Description = '默认表述',
    Url = 'https://blog.yinuosnowball.top',
    PicUrl = 'https://xcx-1251575231.cos.ap-shanghai.myqcloud.com/temp/right.png',
  } = res


  const replyEnum = {
    text: `
  <xml>
    <ToUserName><![CDATA[${FromUserName}]]></ToUserName>
    <FromUserName><![CDATA[${ToUserName}]]></FromUserName>
    <CreateTime>${new Date().getTime()}</CreateTime>
    <MsgType><![CDATA[text]]></MsgType>
    <Content><![CDATA[${Content}]]></Content>
  </xml>
  `,

    image: `
  <xml>
    <ToUserName><![CDATA[${FromUserName}]]></ToUserName>
    <FromUserName><![CDATA[${ToUserName}]]></FromUserName>
    <CreateTime>${new Date().getTime()}</CreateTime>
    <MsgType><![CDATA[image]]></MsgType>
    <Image>
      <MediaId><![CDATA[${MediaId}]]></MediaId>
    </Image>
  </xml>
  `,

    news: `
  <xml>
    <ToUserName><![CDATA[${FromUserName}]]></ToUserName>
    <FromUserName><![CDATA[${ToUserName}]]></FromUserName>
    <CreateTime>${new Date().getTime()}</CreateTime>
    <MsgType><![CDATA[news]]></MsgType>
    <ArticleCount>1</ArticleCount>
    <Articles>
      <item>
        <Title><![CDATA[${Title}]]></Title>
        <Description><![CDATA[${Description}]]></Description>
        <PicUrl><![CDATA[${PicUrl}]]></PicUrl>
        <Url><![CDATA[${Url}]]></Url>
      </item>
    </Articles>
  </xml>
  `
  }
  return replyEnum[MsgType]
}

module.exports = { createResData }